package com.ag.zlw.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ag.bean.TbUnit;
import com.ag.common.AgException;
import com.ag.common.IDUtil;
import com.ag.common.IIDService;
import com.ag.zlw.dao.TbUnitDAO;
import com.ag.zlw.service.UnitService;

/**
 * 物品单位
 * 
 * @author 钟龙伟
 * 
 */

@Service("UnitService")
public class UnitServiceImpl implements UnitService {
	@Resource(name = "ZLWTbUnitDAO")
	private TbUnitDAO tbUnitDAO;

	private String IDs;
	@Resource(name = "iDServiceImpl")
	private IIDService idservice;

	public void save(TbUnit Unit) throws AgException {
		IDs = (String) idservice.findTablePK(IDUtil.TB_UNIT);
		Unit.setUnitId(IDs);
		tbUnitDAO.save(Unit);
	}

	public List<TbUnit> findAll() {
		return tbUnitDAO.findAll();
	}

	public void delete(TbUnit Unit) {
		TbUnit tbUnit = tbUnitDAO.findById(Unit.getUnitId());
		tbUnit.setA(IDUtil.DELETE);
		tbUnitDAO.attachDirty(tbUnit);
	}

	public void modify(TbUnit Unit) {
		tbUnitDAO.attachDirty(Unit);
	}
}
